package utils.utils;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.View;

/**
 * Created by cd5160866 on 2018/1/17.
 */

public class CaputrueUtils {

    public static Bitmap getCaptureView(View view) {
        view.setDrawingCacheEnabled(true);
        view.buildDrawingCache(true);
        Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache(true));
        view.setDrawingCacheEnabled(false);
        return bitmap;
    }

    public static int getStatusBarHeight(Context context) {
        int statusBarHeight = 0;
        int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            statusBarHeight = context.getResources().getDimensionPixelSize(resourceId);
        }
        return statusBarHeight;
    }
}
